#! /bin/bash

#修改apt国内源
echo "deb http://mirrors.ustc.edu.cn/debian/ buster main contrib non-free" > /etc/apt/sources.list
# echo "deb-src http://mirrors.ustc.edu.cn/debian/ buster main contrib non-free" >> /etc/apt/sources.list

echo "deb http://mirrors.ustc.edu.cn/debian/ buster-updates main contrib non-free" >> /etc/apt/sources.list
# echo "deb-src http://mirrors.ustc.edu.cn/debian/ buster-updates main contrib non-free" >> /etc/apt/sources.list

echo "deb http://mirrors.ustc.edu.cn/debian/ buster-backports main contrib non-free" >> /etc/apt/sources.list
# echo "deb-src http://mirrors.ustc.edu.cn/debian/ buster-backports main contrib non-free" >> /etc/apt/sources.list

echo "deb http://mirrors.ustc.edu.cn/debian-security/ buster/updates main contrib non-free" >> /etc/apt/sources.list
# echo "deb-src http://mirrors.ustc.edu.cn/debian-security/ buster/updates main contrib non-free" >> /etc/apt/sources.list
echo -e "\033[32m 已修改apt源为中国科学技术大学源！\033[0m"

#修改pve-no-subscription源
rm -f /etc/apt/sources.list.d/pve-enterprise.list
# echo "deb http://mirrors.ustc.edu.cn/proxmox/debian/pve buster pve-no-subscription " > /etc/apt/sources.list.d/pve-install-repo.list
echo "deb http://mirrors.ustc.edu.cn/proxmox/debian/pve buster pve-no-subscription " > /etc/apt/sources.list.d/pve-install-repo.list
wget http://mirrors.ustc.edu.cn/proxmox/debian/proxmox-ve-release-6.x.gpg -O /etc/apt/trusted.gpg.d/proxmox-ve-release-6.x.gpg
echo -e "\033[32m 已完成修改pve-no-subscription源！\033[0m"

#apt update更新
apt update -y
#pveupdate
#pveupgrade
echo -e "\033[32m 已完成apt更新！\033[0m"

#登陆屏蔽订阅通知
# find / -type f -name "*.js" | xargs  grep -Hn --color=auto "You do not have a valid subscription for this server"
sed -i_orig "s/data.status !== 'Active'/false/g" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
echo -e "\033[32m 已屏蔽登陆订阅通知！\033[0m"

